﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Library;
using Microsoft.Reporting.WinForms;
using QLKH.View.Baocao;

namespace QLKH.View.Hoadon
{
    public partial class ViewHoaDon : Form
    {
        string dateview = "";
        string idkh = "";
        Int16 idduong = 0;
        Int16 iddhtong = 0;
        string ngayphathanh = "";

        public ViewHoaDon(string _dateview,string _idkh,Int16 _idduong,Int16 _iddhtong,string _ngayin)
        {
            InitializeComponent();
            dateview = _dateview;
            idkh = _idkh;
            idduong = _idduong;
            iddhtong = _iddhtong;
            ngayphathanh = _ngayin;
            this.Height = Screen.PrimaryScreen.WorkingArea.Height; //ConfigForm.height;
        }

        private void ViewHoaDon_Load(object sender, EventArgs e)
        {
            clHoadon clhd = new clHoadon();
            DataTable dt = clhd.getHoaDon(dateview, idkh, idduong, iddhtong);
            ReportDataSource rds = new ReportDataSource();
            rds.Name = "DatasetInHoaDon";
            rds.Value = dt;

            this.reportViewerHD.Reset();
            this.reportViewerHD.LocalReport.ReportEmbeddedResource = "QLKH.View.Hoadon.SubIncuoc.rdlc";
            this.reportViewerHD.LocalReport.DataSources.Clear();
            this.reportViewerHD.LocalReport.DataSources.Add(rds);

            //InHoaDon obj1 = new InHoaDon();
            //string ngayin = obj1.dateTimephathanh.Value.ToString("dd/MM/yyyy");

            IList<ReportParameter> param = new List<ReportParameter>();
            param.Add(new ReportParameter("NgayIn", ngayphathanh));
            reportViewerHD.LocalReport.SetParameters(param);

            this.reportViewerHD.RefreshReport();

            this.reportViewerHD.RefreshReport();
            this.reportViewerHD.SetDisplayMode(DisplayMode.PrintLayout);
            this.reportViewerHD.ZoomMode = ZoomMode.Percent;
            this.reportViewerHD.ZoomPercent = 100;

            this.reportViewerHD.PrinterSettings.DefaultPageSettings.Landscape = false;

            //this.reportViewerHD.PrinterSettings.DefaultPageSettings.PaperSize.Width = int.Parse("8.5");
            //this.reportViewerHD.PrinterSettings.DefaultPageSettings.PaperSize.Height = int.Parse("5.5");
            //this.reportViewerHD.RefreshReport();

        }

        private void btquit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
